//The MIT License
//
//Copyright (c) 2009 nodchip
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
package tv.dyndns.kishibe.client.constant;

import com.google.gwt.core.client.GWT;

public class Constant {
	private Constant() {
	}

	public static final int MAX_PROBLEMS_PER_PLAYER = 2;
	public static final int MAX_PLAYER_PER_SESSION = 8;
	public static final int MAX_PROBLEMS_PER_SESSION = MAX_PLAYER_PER_SESSION
			* MAX_PROBLEMS_PER_PLAYER;
	public static final int MAX_PERFECT_BORDER_TIME = 0;
	public static final double MAX_POINT_COMPRESS = 0.5;
	public static final double MIN_POINT_COMPRESS = 0.5;
	public static final int MAX_POINT = 10000;
	// public static final int WAIT_SECOND_FOR_MATCHING = 10;
	public static final int WAIT_SECOND_FOR_MATCHING = 100;
	public static final int SECONDS_FROM_READY_TO_PROBLEM = 10;
	public static final int MAX_TIMING_DELAY = 200;
	private static final String[] CLASS_NAMES = { "ヴァンパイア", "トロール", "ユニコーン", "ホムンクルス", "ミノタウロス",
			"ガーゴイル", "クラーケン", "リザードマン", "スフィンクス", "デュラハン", "グレムリン", "ケンタウロス", "ゾンビ", "ヘルハウンド",
			"カーバンクル", "マンドレイク", "ヒドラ", "ドッペルゲンガー", "サラマンダー", "ゴーレム", "グリフォン", "ロック", "フェンリル",
			"ワルキューレ", "ケルベロス", "ワーウルフ", "サイクロプス", "キマイラ", "イフリート", "バジリスク", "マンティコア", "マーメイド",
			"オーク", "バンシー", "バルログ", "ジャバウォック", "フェニックス", "ケットシー", "ケツァルコアトル", "メドゥーサ", "リバイアサン",
			"ワイバーン", "鵺", "ケルピー", "マミー", "スキュラ", "ペガサス", "カロン", "ヒポグリフ", "ベヒモス", "サンダーバード",
			"シーサーペント", "麒麟", "イエティ", "インキュバス", "サキュバス", "スライム", "エント", "コカトリス", "ブラウニー",
			"バンダースナッチ", "ペリュトン", "パビルサグ", "ミミック", "ジャック・オ・ランタン", "ポルターガイスト", "ノーム", "クネヒト・ルプレヒト",
			"ドラゴン", "エルフ", "ドワーフ", "天狗", "龍", "ウンディーネ", "ウィル・オ・ザ・ウィスプ", "ゴブリン", "リャナンシー", "オーガ",
			"ホビット", "スレイプニル", "スマウグ", "ネメアンライオン", "アルゴス", "エキドナ", "ムスッペル", "ミルメコレオ", "パズズ", "タロス",
			"カクス", "アモン", "ヘカトンケイル", "エコー", "メフィストフェレス", "ギガース", "シルフ", "エンジェル", "キューピッド",
			"チョンチョン", "開明獣", "九尾の狐", "コロポックル", "河童", "ガルーダ", "ナーガ", "バロン", "ギリメカラ", "クサントス",
			"バリオス", "八岐大蛇", "酒呑童子", "蚩尤", "八咫烏", "セルキー", "ハンプティ・ダンプティ", "フンババ", "リー・バン", "リッチ" };
	public static final int NUMBER_OF_CLASSES = CLASS_NAMES.length;
	private static final int DIFFICULTY_UPPER_START = 100;
	private static final int DIFFICULTY_LOWER_START = 80;
	private static final int DIFFICULTY_UPPER_FINISH = 25;
	private static final int DIFFICULTY_LOWER_FINISH = 0;
	private static final int DIFFICULTY[][] = createDifficulty();
	public static final int DIFFICULT_SELECT_NORMAL = 0;
	public static final int DIFFICULT_SELECT_DIFFICULT = 1;
	public static final int DIFFICULT_SELECT_EASY = 2;
	public static final int DIFFICULT_SELECT_LITTLE_DIFFICULT = 3;
	public static final int DIFFICULT_SELECT_LITTLE_EASY = 4;
	public static final int MAX_CLASS_LEVEL = CLASS_NAMES.length - 1;
	public static final int CLASS_LEVEL_NORMAL = MAX_CLASS_LEVEL + 1;
	public static final int CLASS_LEVEL_DIFFICULT = MAX_CLASS_LEVEL + 2;
	public static final int CLASS_LEVEL_EASY = MAX_CLASS_LEVEL + 3;
	public static final int CLASS_LEVEL_LITTLE_DIFFICULT = MAX_CLASS_LEVEL + 4;
	public static final int CLASS_LEVEL_LITTLE_EASY = MAX_CLASS_LEVEL + 5;
	public static final int STEP_PER_CLASS_LEVEL = 4;
	public static final int RETRY_DELAY = 1000;
	public static final String DEPROY_DIRECTORY = "/QMAClone";
	public static final int REPORT_NOT_YET = 10;
	public static final int MAX_RATIO_CALCULATING = 10;
	public static final String WAIT_SPACE = "                              ";
	public static final int FIXED_CLASS_LEVEL = -1;
	public static final String DELIMITER_GENERAL = "\n";
	public static final String DELIMITER_JUNBAN = ">";
	public static final String DELIMITER_KUMIAWASE_PAIR = "<--->";
	public static final String FORM_NAME_USER_CODE = "user_code";
	public static final String FORM_NAME_ICON = "icon";
	public static final String ICON_UPLOAD_RESPONSE_OK = "--OK--";
	public static final String ICON_UPLOAD_RESPONSE_FAILED_TO_PARSE_REQUEST = "--FAILED_TO_PARSE_REQUEST--";
	public static final String ICON_UPLOAD_RESPONSE_FAILED_TO_DETECT_IMAGE_FILE_TYPE = "--FAILED_TO_DETECT_IMAGE_FILE_TYPE--";
	public static final String ICON_UPLOAD_RESPONSE_REQUEST_FORMAT_ERROR = "--REQUEST_FORMAT_ERROR--";
	public static final String ICON_UPLOAD_RESPONSE_IMAGE_FILE_NAME_FORMAT_ERROR = "--IMAGE_FILE_NAME_FORMAT_ERROR--";
	public static final String ICON_URL_PREFIX = "http://kishibe.dyndns.tv/qmaclone_icon/";
	public static final String FILE_PATH_BASE = "/var/www/";
	public static final String ICON_FOLDER_PATH = FILE_PATH_BASE + "qmaclone_icon/";
	public static final int ICON_SIZE = 48;
	public static final int ICON_SIZE_BIG = 64;
	public static final String ICON_NO_IMAGE = "noimage.jpg";
	public static final String SOUND_URL_PREFIX = "http://kishibe.dyndns.tv/qmaclone_sound/";
	public static final String SOUND_URL_GOOD = SOUND_URL_PREFIX + "chime00.wav";
	public static final String SOUND_URL_BAD = SOUND_URL_PREFIX + "beep14.wav";
	public static final String SOUND_URL_TIME_UP = SOUND_URL_PREFIX + "bell02.wav";
	public static final String SOUND_URL_BUTTON_OK = SOUND_URL_PREFIX + "weapon01.wav";
	public static final String SOUND_URL_BUTTON_PUSH = SOUND_URL_PREFIX + "wood07.wav";
	public static final String SOUND_URL_READY_FOR_GAME = SOUND_URL_PREFIX + "bell00.wav";
	public static final int RANKING_DISPLAY_DAY = 30;
	public static final int NUMBER_OF_RANKING_DATA = 100;
	public static final int RANKING_HIGH_SCORE = 0;
	public static final int RANKING_AVERAGE_SCORE = 1;
	public static final int RANKING_PLAY_COUNT = 2;
	public static final int RANKING_VICTORY_POINT = 3;
	public static final int RANKING_AVERAGE_RANK = 4;
	public static final int RANKING_CLASS = 5;
	public static final int RANKING_CORRECT_RATIO = 6;
	public static final int NUMBER_OF_RANKING_TYPE = 7;
	public static final int BBS_THREADS_PER_PAGE = 5;
	public static final int BBS_INITIAL_RESPONSE_PER_THREAD = 10;
	public static final int BBS_DISPLAY_INFO_ANONYMOUS = 0;
	public static final int BBS_DISPLAY_INFO_NAME_ONLY = 1;
	public static final int BBS_DISPLAY_INFO_ALL_DATA = 2;
	// public static final String NAMES_OF_GENRE[] = { "ノンジャンル", "アニメ＆ゲーム", "スポーツ", "芸能", "ライフスタイル",
	// "社会", "文系学問", "理系学問", "未分類" };
	// public static final String INITIAL_OF_GENRE[] = { "ノ", "ア", "ス", "芸", "ラ", "社", "文", "理", "未"
	// };
	public static final int LINK_DATA_PER_PAGE = 10;
	public static final String[] PREFECTURE_NAMES = { "無所属", "北海道", "青森", "岩手", "宮城", "秋田", "山形",
			"福島", "茨城", "栃木", "群馬", "埼玉", "千葉", "東京", "神奈川", "新潟", "富山", "石川", "福井", "山梨", "長野",
			"岐阜", "静岡", "愛知", "三重", "滋賀", "京都", "大阪", "兵庫", "奈良", "和歌山", "鳥取", "島根", "岡山", "広島",
			"山口", "徳島", "香川", "愛媛", "高知", "福岡", "佐賀", "長崎", "熊本", "大分", "宮崎", "鹿児島", "沖縄", };
	public static final int MAX_RATING_HISTORY = 100;
	public static final int RATING_DISTRIBUTION_WIDTH = 20;
	public static final int CLICK_IMAGE_WIDTH = 512;
	public static final int CLICK_IMAGE_HEIGHT = 384;
	public static final int CHAT_MAX_RESPONSES = 100;
	public static final int NEW_PROBLEM_ID = -1;
	public static final int MIN_NUMBER_OF_THEME_MODE_PROBLEMS = 100;
	public static final int MAX_NUMBER_OF_CREATION_PER_HOUR = 3;
	public static final int WEB_SOCKET_PORT = 60080;
	public static final String WEB_SOCKET_URL = GWT.isProdMode() ? ("ws://kishibe.dyndns.tv:" + WEB_SOCKET_PORT)
			: ("ws://localhost:" + WEB_SOCKET_PORT);
	public static final int MAX_NUMBER_OF_ANSWERS = 8;
	public static final int MAX_NUMBER_OF_CHOICES = 8;

	private static final int[][] createDifficulty() {
		final int numberOfClasses = CLASS_NAMES.length;
		final int difficulty[][] = new int[numberOfClasses + 5][2];
		difficulty[numberOfClasses][0] = 0;
		difficulty[numberOfClasses][1] = 100;
		difficulty[numberOfClasses + 1][0] = 0;
		difficulty[numberOfClasses + 1][1] = 30;
		difficulty[numberOfClasses + 2][0] = 70;
		difficulty[numberOfClasses + 2][1] = 100;
		difficulty[numberOfClasses + 3][0] = 20;
		difficulty[numberOfClasses + 3][1] = 50;
		difficulty[numberOfClasses + 4][0] = 50;
		difficulty[numberOfClasses + 4][1] = 80;

		for (int i = 0; i < numberOfClasses; ++i) {
			final int lower = (DIFFICULTY_LOWER_START - DIFFICULTY_LOWER_FINISH)
					* (numberOfClasses - i) / numberOfClasses + DIFFICULTY_LOWER_FINISH;
			final int upper = (DIFFICULTY_UPPER_START - DIFFICULTY_UPPER_FINISH)
					* (numberOfClasses - i) / numberOfClasses + DIFFICULTY_UPPER_FINISH;
			difficulty[i][0] = lower;
			difficulty[i][1] = upper;
		}

		return difficulty;
	}

	public static final String getClassName(int classLevel) {
		return CLASS_NAMES[classLevel];
	}

	public static final int getDifficultyLower(int classLevel) {
		return DIFFICULTY[classLevel][0];
	}

	public static final int getDifficultyUpper(int classLevel) {
		return DIFFICULTY[classLevel][1];
	}
}
